package edu.unf.cen6940.converter;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.Formatter;
import org.springframework.format.FormatterRegistry;
import org.springframework.format.support.FormattingConversionServiceFactoryBean;

import edu.unf.cen6940.domain.Category;
import edu.unf.cen6940.domain.Faculty;
import edu.unf.cen6940.domain.Generatedproduct;
import edu.unf.cen6940.domain.Researchkeyword;
import edu.unf.cen6940.domain.Student;
import edu.unf.cen6940.domain.Thesiscommittee;
import edu.unf.cen6940.domain.Thesistool;

public class ConfigurableFormattingConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean {
	private Map<String, Formatter> formatters;

	@Autowired
	StudentConverter studentConverter;
	
	@Autowired
	FacultyConverter facultyConverter;

	@Autowired
	CategoryConverter categoryConverter;
	
	@Autowired
	ThesistoolConverter thesistoolConverter;
	
	@Autowired
	GenerateproductConverter generateproductConverter;
	
	@Autowired
	ThesiscommitteeConverter thesiscommitteeConverter;
	
	@Autowired
	ResearchkeywordConverter researchkeywordConverter;
	
    public void setFormatters(Map<String, Formatter> formatters){
        this.formatters = formatters;
    }

    @Override
    protected void installFormatters(FormatterRegistry registry) {
        super.installFormatters(registry);
        registry.addFormatterForFieldType(Student.class, studentConverter);
        registry.addFormatterForFieldType(Faculty.class, facultyConverter);
        registry.addFormatterForFieldType(Category.class, categoryConverter);
        registry.addFormatterForFieldType(Thesistool.class, thesistoolConverter);
        registry.addFormatterForFieldType(Generatedproduct.class, generateproductConverter);
        registry.addFormatterForFieldType(Thesiscommittee.class, thesiscommitteeConverter);
        registry.addFormatterForFieldType(Researchkeyword.class, researchkeywordConverter);
    }

}
